﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ProtocolConversion_WINCE
{
    class GPS
    {
        private static Form1 form1 = new Form1();
        public static void SegmentMessage(byte[] date, int length, string cmd)
        {
            //externalPowerPressure = Converter.BytesToUInt16(date, 10);

            byte[] returnFrameCMDByte = new byte[2];
            //查询CMD 字典
            if (Form1.ReturnFrameCMDByteDic.TryGetValue(cmd, out returnFrameCMDByte))
            {
                //检查校验字
                //if (Form1.CompareDate(Converter.TakeOutByteNoOrder(date, length - 2, 2), Form1.CalculateCheckByte(date)))
                {
                    //未收到GPS信号
                    if (Converter.BytesToUInt16(date, 12) == 1)
                    {
                        //将数据填充到协议当中
                        if (Form1.FillDate(new byte[] { 0x11, 0x11 }, 22, 2))
                        {
                            //form1.textBox4.Text += "GPS值添加成功\t\n";
                        }
                        else
                        {
                            //form1.textBox4.Text += "GPS值添加失败\t\n";
                        }
                    }
                    else
                    {
                        //将数据填充到协议当中
                        if (Form1.FillDate(new byte[] { 0xff, 0xff }, 22, 2))
                        {
                            //form1.textBox4.Text += "GPS值添加成功\t\n";
                        }
                        else
                        {
                            //form1.textBox4.Text += "GPS值添加失败\t\n";
                        }
                    }
                }
                //else
                //{
                //    form1.textBox4.Text += "获取的温度值的校验字不匹配\t\n";
                //}
            }
            else
            {
                //form1.textBox4.Text += "未从字典中提取到温度命令对应的数据\t\n";
            }
        }
    }
}
